<?php
class admin_categoryController extends adminController{

    //模型列表
    public function index()
    {
        $this->list=model('expand_model')->model_list();
        $this->show();
    }

    public function data_check($data)
    {
        if(model('expand_model')->table_info($data['table'],$data['mid'])){
            $this->msg('表名不能重复！',0);
        }
    }

    //模型添加
    public function add()
    {
        $this->action_name='添加';
        $this->action='add';
        $this->list=model('expand_model')->model_list();
        $this->show('admin_category/info');
    }

    public function add_save()
    {
        $this->data_check($_POST);    
        model('expand_model')->add($_POST);    
        $this->msg('模型添加成功！',1);
    }

    //模型修改
    public function edit()
    {
        $mid=intval($_GET['mid']);
        $this->alert_str($mid,'int');
        $this->action_name='编辑';
        $this->action='edit';
        $this->info=model('expand_model')->info($mid);
        $this->show('admin_category/info');
    }

    public function edit_save()
    {
        //录入模型处理
        $mid=intval($_POST['mid']);
        $this->alert_str($mid,'int',true);
        $this->data_check($_POST);
        model('expand_model')->edit($_POST);
        $this->msg('模型修改成功！',1);
    }

    //删除
    public function del()
    {
        $mid=intval($_POST['mid']);
        $this->alert_str($mid,'int',true);
        //删除模型
        model('expand_model')->del($_POST);
        $this->msg('模型删除成功！',1);

    }

}